package cn.edu.scau.cmi.huangxiyan.composite;

import java.util.Set;

public class ConsistentLeaf extends ConsistentComponent {
	private String name = "";
	private ConsistentComposite parent = null;

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setParent(ConsistentComposite parent) {
		this.parent = parent;
	}

	@Override
	public ConsistentComposite getParent() {
		return this.parent;
	}

	@Override
	public String doSomething() {
		return "我是一致性组合模式中的叶子节点组件";
	}

	@Override
	public int hashCode() {
		return this.getName().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		ConsistentLeaf leaf = (ConsistentLeaf) obj;
		if (this.getName().equals(leaf.getName())) {
			return true;
		}
		return false;
	}

	@Override
	public Set<ConsistentComponent> getChildren() {
		return null;
	}

	@Override
	public void addChild(ConsistentComponent child) {
	}

	@Override
	public void removeChild(ConsistentComponent child) {
	}

}
